﻿using System;
using System.Collections.Generic;

namespace asoptions
{
    /// <summary>
    /// Specifies what each node represents in a TreeView. Intended to be used
    /// in TreeNode.Tag.
    /// </summary>
    enum NodeType
    {
        Folder,
        Song,
        Tag,
        OptionTag
    }

    /// <summary>
    /// Used to specify type of message for logging purposes.
    /// </summary>
    public enum MessageType
    {
        Info,
        ToAS,
        FromAS,
        Error,
        Warning
    }

    /// <summary>
    /// Bitmask used to specify tag options for a song.
    /// </summary>
    [FlagsAttribute]
    enum TagOptions : int
    {
        AllDefault = 0,
        FourLane = 1,
        NoStealthBonus = 2,
        LongChains = 4,
        InvGrid = 8,
        IncSpeed = 16,
        MonoBasePts = 32,
        MinMatchSize = 64,
        PerWhiteBlock = 128,
        MatchTicks = 256,
        RowCount = 512,
        CharMonoRestr = 1024,
        MonoGray = 2048,
        Camera = 4096,
        Portal = 8192
    };

    /// <summary>
    /// All possible Audiosurf characters.
    /// </summary>
    public enum Characters
    {
        mono, pointman, doublevision,
        monopro, vegas, eraser, pointmanpro, pusher, doublevisionpro,
        ninjamono, eraserelite, pointmanelite, pusherelite, doublevisionelite,
        freeride
    }

    /// <summary>
    /// Bitmask to specify current state of Audiosurf
    /// </summary>
    [FlagsAttribute]
    enum CurrentState : int
    {
        Closed = 0,
        Connected = 1,
        CharScreen = 2,
        InSong = 4
    }

    public class Song
    {
        public string fullPath { get; set; }
        public string fileName { get; set; }
        public string title { get; private set; }
        public string artist { get; private set; }
        public Characters aschar { get; set; }

        /// <summary>
        /// Creates a Song
        /// </summary>
        /// <param name="p">Full path (including file name)</param>
        /// <param name="n">File name (excluding path)</param>
        public Song(string p, string n)
        {
            fullPath = p;
            fileName = n;
            using (var f = TagLib.File.Create(fullPath))
            {
                title = f.Tag.Title;
                artist = f.Tag.FirstPerformer;
            }
            aschar = (Characters)Properties.Settings.Default.defaultChar;
        }

        public override string ToString()
        {
            return fileName + " (" + title + ")";
        }

        public bool Equals(Song other)
        {
            return ((this.fullPath == other.fullPath) &&
                    (this.fileName == other.fileName) &&
                    (this.title == other.title));
        }
    }

    /// <summary>
    /// Used to add a message to the log using an event
    /// </summary>
    public class LogMessageEventArgs : EventArgs
    {
        /// <summary>
        /// Message to append to the log
        /// </summary>
        public string message { get; set; }

        /// <summary>
        /// Type of message
        /// </summary>
        public MessageType type { get; set; }
    }
}